//
//  WeatherView.m
//  iNews
//
//  Created by lanou3g on 14-12-12.
//  Copyright (c) 2014年 张在青. All rights reserved.
//

#import "WeatherView.h"
#import "WeatherModel.h"

@implementation WeatherView

- (void)dealloc
{
    [_backButton release];
    [_v1 release];
    [_parmeStr release];
    
    [super dealloc];
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self addAllViews];
        
    }
    return self;
}



- (void)addAllViews
{
   
    self.v1 = [[[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds] autorelease];
    [self addSubview:self.v1];
    
    UIImageView *im = [[[UIImageView alloc]init] autorelease];
    im.frame = CGRectMake(0, 0, CGRectGetWidth(self.v1.frame), CGRectGetHeight(self.v1.frame)*2/3 - 20);
    im.image = [UIImage imageNamed:@"QingTian.jpg"];
    im.tag = 135;
    [self.v1 addSubview:im];
    
    
    self.backButton = [UIButton buttonWithType:UIButtonTypeSystem];
     self.backButton.frame = CGRectMake(20, 50, 40, 30);
    [self.backButton setBackgroundImage:[UIImage imageNamed:@"5.jpg"] forState:UIControlStateNormal];
    [self.v1 addSubview:self.backButton];
    

    UIImageView *im1 = [[[UIImageView alloc]init] autorelease];
    
    im1.frame = CGRectMake(0, CGRectGetHeight(self.v1.frame)*2/3 - 20, CGRectGetWidth(self.v1.frame), CGRectGetHeight(self.v1.frame)/3 + 20);
    
    im1.image = [UIImage imageNamed:@"QingTian-1.jpg"];
    
    im1.tag = 136;
    
    
    [self.v1 addSubview:im1];
    
    UIImageView *image = [[[UIImageView alloc]init] autorelease];
    
    image.frame = CGRectMake(120, 80, 80, 80);
    
    image.frame = CGRectMake(CGRectGetWidth(im.frame)/2 - CGRectGetWidth(image.frame)/2, 80, 80, 80);
    
    image.image = [UIImage imageNamed:@"sun0101@2x.png"];
    
    //    image.backgroundColor = [UIColor yellowColor];
    
    [self.v1 addSubview:image];
    
    UILabel *l1 = [[[UILabel alloc]init] autorelease];
    
    //    l1.frame = CGRectMake(90, CGRectGetMaxY(image.frame) + 10, 140, 20);
    
    //    l1.frame = CGRectMake((CGRectGetWidth(self.v1.frame) - CGRectGetWidth(l1.frame))/2 , CGRectGetMaxY(image.frame) + 10, 140, 20);
    
    
    CGRect rect = CGRectMake(100, CGRectGetMaxY(image.frame) + 10, 120, 25);
    
    l1.frame = CGRectMake(CGRectGetMidX(image.frame) - rect.size.width/2, CGRectGetMaxY(image.frame) + 10, 120, 20);
    
    //    l1.backgroundColor = [UIColor yellowColor];
    
    l1.font = [UIFont fontWithName:@"Helvetica-Bold" size:16];
    
    l1.text = @"萨发12";
    
    l1.textAlignment = NSTextAlignmentCenter;
    
    l1.tag = 130;
    
    l1.textColor = [UIColor whiteColor];
    
    
    [self.v1 addSubview:l1];
    
    UILabel *l2 = [[[UILabel alloc]init] autorelease];
    
    l2.frame = CGRectMake(70, CGRectGetMaxY(l1.frame) + 10, 60, 20);
    
    //    l2.backgroundColor = [UIColor yellowColor];
    
    l2.font = [UIFont fontWithName:@"Helvetica-Bold" size:16];
    
    l2.text = @"萨发12";
    
    l2.textAlignment = NSTextAlignmentCenter;
    
    l2.tag = 131;
    
    l2.textColor = [UIColor whiteColor];
    
    
    [self.v1 addSubview:l2];
    
    UILabel *l3 = [[[UILabel alloc]init] autorelease];
    
    l3.frame = CGRectMake(CGRectGetMaxX(l2.frame) + 10, CGRectGetMinY(l2.frame), 90, 20);
    
    //    l3.backgroundColor = [UIColor yellowColor];
    
    l3.textAlignment = NSTextAlignmentCenter;
    
    l3.tag = 132;
    
    l3.textColor = [UIColor whiteColor];
    
    
    [self.v1 addSubview:l3];
    
    UILabel *l4 = [[[UILabel alloc]init] autorelease];
    
    l4.frame = CGRectMake(80, CGRectGetMaxY(l2.frame) + 10, 40, 20);
    
    //    l4.backgroundColor = [UIColor yellowColor];
    
    l4.textAlignment = NSTextAlignmentCenter;
    
    l4.tag = 133;
    
    l4.textColor = [UIColor whiteColor];
    
    
    [self.v1 addSubview:l4];
    
    UILabel *l5 = [[[UILabel alloc]init] autorelease];
    
    l5.frame = CGRectMake(CGRectGetMaxX(l4.frame) + 20, CGRectGetMinY(l4.frame), 140, 20);
    
    //    l5.backgroundColor = [UIColor yellowColor];
    
    l5.font = [UIFont fontWithName:@"Helvetica-Bold" size:16];
    
    l5.textAlignment = NSTextAlignmentCenter;
    
    l5.tag = 134;
    
    l5.textColor = [UIColor whiteColor];
    
    
    [self.v1 addSubview:l5];
    
    
    
    
    for (int i = 1; i <= 3; i++) {
        
        UIImageView *uv = [[[UIImageView alloc]init] autorelease];
        
        
        uv.frame = CGRectMake(40 + (i -1 ) * ((CGRectGetWidth(self.v1.frame) - 2 * 40 - 3 * 50)/2 + 50), CGRectGetHeight(self.v1.frame)/3*2, 50, 50);
        
        uv.tag = 100 + i;
     //   NSString *s = [NSString stringWithFormat:@"%ld",(long)uv.tag];
        
        //        uv.backgroundColor = [UIColor yellowColor];
        
        uv.image = [UIImage imageNamed:@"sun0101@2x.png"];
        
        [self.v1 addSubview: uv];
        
        
    }
    
    int m = 0;
    
    for (int j = 1; j <= 4; j++)
        
        for (int i = 1; i <= 3; i++) {
            
            UILabel *uil = [[[UILabel alloc]init] autorelease];
            uil.frame = CGRectMake(20 + (i -1 ) * ((CGRectGetWidth(self.v1.frame) - 2 * 20 - 3 * 90)/2 + 90), CGRectGetHeight(self.v1.frame)/4*3 + 18 *j, 90, 15);
            uil.tag = 110 + m + 1;
            uil.font = [UIFont fontWithName:@"Helvetica-Bold" size:12];
            uil.text = @"大师傅的说法范德萨发";
            uil.textColor = [UIColor whiteColor];
            uil.textAlignment = NSTextAlignmentCenter;
            [self.v1 addSubview: uil];
            m++;
        }
    
}

- (void)writeMessageWithModel:(WeatherModel *)Model
{
    
//    UILabel *lab1=(UILabel *)[self viewWithTag:111];
//    UILabel *lab2=(UILabel *)[self viewWithTag:114];
//    UILabel *lab3=(UILabel *)[self viewWithTag:117];
//    UILabel *lab4=(UILabel *)[self viewWithTag:120];
//    
//    UILabel *lab5=(UILabel *)[self viewWithTag:112];
//    UILabel *lab6=(UILabel *)[self viewWithTag:115];
//    UILabel *lab7=(UILabel *)[self viewWithTag:118];
//    UILabel *lab8=(UILabel *)[self viewWithTag:121];
//    
//    UILabel *lab9=(UILabel *)[self viewWithTag:113];
//    UILabel *lab10=(UILabel *)[self viewWithTag:116];
//    UILabel *lab11=(UILabel *)[self viewWithTag:119];
//    UILabel *lab12=(UILabel *)[self viewWithTag:122];
//    
    
//    Model *mo0 = [NetDataHande shareNetData].aArray[0];
//    Model *mo = [NetDataHande shareNetData].aArray[1];
//    Model *mo1 = [NetDataHande shareNetData].aArray[2];
//    Model *mo2 = [NetDataHande shareNetData].aArray[3];
//    
//    
//    lab1.text = mo.week;
//    lab2.text = mo.temperature;
//    lab3.text = mo.climate;
//    lab4.text = mo.wind;
//    
//    lab5.text = mo1.week;
//    lab6.text = mo1.temperature;
//    lab7.text = mo1.climate;
//    lab8.text = mo1.wind;
//    
//    lab9.text = mo2.week;
//    lab10.text = mo2.temperature;
//    lab11.text = mo2.climate;
//    lab12.text = mo2.wind;
//    
//    UILabel *l1 = (UILabel *)[self.rv viewWithTag:130];
//    
//    l1.text = [NetDataHande shareNetData].dt;
//    
//    UILabel *l2 = (UILabel *)[self.rv viewWithTag:131];
//    
//    l2.text = mo0.week;
//    
//    UILabel *l3 = (UILabel *)[self.rv viewWithTag:132];
//    
//    l3.text = mo0.temperature;
//    
//    UILabel *l4 = (UILabel *)[self.rv viewWithTag:133];
//    
//    l4.text = mo0.climate;
//    
//    UILabel *l5 = (UILabel *)[self.rv viewWithTag:134];
//    
//    l5.text = mo0.wind;
//    
//    UIImageView *im = (UIImageView *)[self.rv viewWithTag:135];
//    
//    [im setImageWithURL:[NetDataHande shareNetData].d[@"nbg1"] placeholderImage:[UIImage imageNamed:@"QingTian"]];
//    
//    UIImageView *im1 = (UIImageView *)[self.rv viewWithTag:136];
//    
//    [im1 setImageWithURL:[NetDataHande shareNetData].d[@"nbg2"] placeholderImage:[UIImage imageNamed:@"QingTian-1"]];
    

}









@end
